package GUI;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.util.List;

import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;

import Model.Conference;
import Model.User;

/**
 * This class represents the user screen for the program chair of a conference.
 * Layout is the same as a PaperPanel.
 * 
 * @author Irving Estrera
 * @version Reused Paul Shultz's AuthorTool Panel's format for its layout.
 * */
@SuppressWarnings("serial")
public class ProgramChairPanel extends JPanel
{
  private Conference my_conference;
  private User my_curr_user;

  /**
   * The panel for the program chair.
   * 
   * @param the_user
   *          The program chair
   * @param the_conf
   *          The conference
   * @param the_frame
   *          The current frame this panel is placed on
   * */
  public ProgramChairPanel(final Conference the_conf, final User the_user,
      final ConferenceWizardFrame the_frame)
  {
    super();
    my_conference = the_conf;
    my_curr_user = the_user;
    setLayout(new BorderLayout());
    setPreferredSize(new Dimension(550, 600));
    setBackground(Color.WHITE);

    JLabel header = new JLabel("Program Chair Tool");
    header.setForeground(Color.BLUE);
    header.setFont(new Font("Plain", Font.BOLD, 38));

    JPanel title = new JPanel(new FlowLayout(FlowLayout.LEADING));
    title.setBackground(Color.WHITE);
    title.add(header);

    JLabel decision_instructions = new JLabel("To edit a decision "
        + "for a paper, please select Edit Decision.");
    decision_instructions.setForeground(Color.RED);
    decision_instructions.setFont(new Font("Plain", Font.PLAIN, 16));

    JLabel rec_instructions = new JLabel("To download a recommendation "
        + "for a paper, click recommendation.");
    rec_instructions.setForeground(Color.RED);
    rec_instructions.setFont(new Font("Plain", Font.PLAIN, 16));
    
    JLabel assign_instructions = new JLabel("To assign a paper to "
        + "a subprogram chair, please click Assign.");

    JPanel instructions_panel = new JPanel(new FlowLayout(FlowLayout.LEADING));
    JPanel instructions_panel2 = new JPanel(new FlowLayout(FlowLayout.LEADING));
    JPanel instructions_panel3 = new JPanel(new FlowLayout(FlowLayout.LEADING));

    instructions_panel.add(decision_instructions);
    instructions_panel2.add(assign_instructions);
    instructions_panel3.add(rec_instructions);

    JPanel north_panel = new JPanel();
    north_panel.setLayout(new BoxLayout(north_panel, BoxLayout.Y_AXIS));
    north_panel.setBackground(Color.WHITE);

    north_panel.add(title);
    north_panel.add(Box.createVerticalStrut(10));
    north_panel.add(instructions_panel);
    north_panel.add(instructions_panel3);
    north_panel.add(instructions_panel2);
    add(north_panel, BorderLayout.NORTH);

    JPanel papers_panel = new JPanel();
    papers_panel.setLayout(new BoxLayout(papers_panel, BoxLayout.Y_AXIS));
    papers_panel.setBackground(Color.WHITE);

    JLabel submitted_papers_label = new JLabel("Submitted Papers:");
    submitted_papers_label.setFont(new Font("Plain", Font.PLAIN, 28));
    submitted_papers_label.setForeground(new Color(0, 102, 204));

    papers_panel.add(submitted_papers_label);
    papers_panel.add(Box.createVerticalStrut(20));

    List<Model.Paper> papers = the_conf.getSubmittedPapers();
//    System.out.println(papers);
    // JPanel assignPanel = new JPanel();
    JLabel sub_chair_label = new JLabel();
    for (Model.Paper p : papers)
    {
      papers_panel.add(new PaperStatusPanel(my_conference, my_curr_user, p,
          the_frame));
      papers_panel.add(sub_chair_label);
      papers_panel.add(Box.createVerticalStrut(30));
    }
    JScrollPane scroll_panel = new JScrollPane(papers_panel);
    add(scroll_panel, BorderLayout.CENTER);
  }

}
